<?php
if ($_POST['submit'] == 'client_req')
{
	$username = $_POST['uname'];
	$password = $_POST['pwd'];
	$ip = $_SERVER['REMOTE_ADDR'];
	
	try {
		$db = new SQLiteDatabase("dummychat.db", 0666, $sqerr);
		$fetch = $db -> query('SELECT username, password FROM UserDB WHERE username = "'.$username.'"') -> fetch();
		if ( $fetch['password'] != $password || ( $username == '' || $password == '' ) )
			echo "Failure";
		else {
			$db -> query('UPDATE UserDB SET address="'.$ip.'", status=1 WHERE username="'.$username.'"');
			echo "Success";
		}
	}
	catch (Exception $e) {
		echo "Database";
	}
}